import java.util.Random;
import java.util.Scanner;

public class HeroDemo {

    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请为第一位英雄设置名称：(输入名称后回车继续)");
        String name1 = sc.next();
        System.out.println("请为第二位英雄设置名称：(输入名称后回车继续)");
        String name2 = sc.next();
        int [] skillHurts = {50,60,70,100};
        String [] skill1 = {"技能一","技能二","技能三","技能四"};
        Hero cxk = new Hero(name1,skill1,skillHurts,700.0);
        String [] skill2 = {"技能五","技能六","技能七","技能八"};
        Hero wyf = new Hero(name2,skill2,skillHurts,700.0);
        System.out.println("首先摇色子随机判断谁先出手。");
        Random r = new Random();
        int i = r.nextInt(2);
        if(i==0) {
            System.out.println("摇到 "+i+" ,"+cxk.getName()+"先开始进攻"+wyf.getName());
            while(true) {
                if(cxk.getHp()<=0) {System.out.println(cxk.getName()+"的血量低于或者等于0,"+wyf.getName()+"获胜。");break;}
                cxk.attack(wyf);
                if(wyf.getHp()<=0) {System.out.println(wyf.getName()+"的血量低于或者等于0,"+cxk.getName()+"获胜。");break;}
                wyf.attack(cxk);
            }
        }else if(i==1) {
            System.out.println("摇到 "+i+" ,"+wyf.getName()+"先开始进攻"+cxk.getName());
            while(true) {
                if(wyf.getHp()<=0) {System.out.println(wyf.getName()+"的血量低于或者等于0,"+cxk.getName()+"获胜。");break;}
                wyf.attack(cxk);
                if(cxk.getHp()<=0) {System.out.println(cxk.getName()+"的血量低于或者等于0,"+wyf.getName()+"获胜。");break;}
                cxk.attack(wyf);
            }
        }

    }
}
